/* 收支管理  */
var firstShouzhixx = true;
var getShzList = function(url,url2){
	cwIncomeExpensesDetail(url2);
	if(firstShouzhixx) {
		firstShouzhixx = false;
		winWidth = $(window).width()-200;
	   	winHeight = $(window).height() / 2.5;
	   	var win = winWidth / 8;
	    $.jgrid.defaults.styleUI = 'Bootstrap';
		$("#table_list_2").jqGrid({
			postData:{busiId:busiId},
			url:url,
	       	datatype : "json",
	        colNames : ['主键', '入账日期', '费用项目码', '费用项目', '收入/支出码', '收入/支出', '金额','收支方式', '收支账号',  '备注'],
	        colModel : [ 
	                     {name: 'replaceId', index: 'id', hidden:true},
	            		 {name: 'dateItem',index: 'dateItem',width: win,align: "left", formatter:function(a) {
	                    	 return formateDate(a);
	                     }},
	                     {name: 'itemCode',index: 'itemCode',hidden:true},
	            		 {name: 'itemCodeDisplay',index: 'itemCode',width: win,align: "left"},
	            		 {name: 'itemDirection',index: 'itemDirection',hidden:true},
	                  	 {name: 'itemDirectionDisplay',index: 'itemDirection',width: win,align: "left"},
	               		 {name: 'amountItem',index: 'amountItem',width: win,align: "left",formatter:function(a){
	                    	 return showNumber(a);
	                     }},
	               		 {name: 'typeRemitDisplay',index: 'typeRemit',width: win,align: "left"},
	            		 {name: 'cardnoItem',index: 'cardnoItem',width: win,align: "left"},
	            		 {name: 'remarks',index: 'remarks',width: win,align: "left"}
	                   ],
	           mtype : "post",
	           height: winHeight,
	           autowidth: true,
	           shrinkToFit: true,
	           rowNum: 30,
	           rowList: [30, 60, 90, 120, 150],
	           viewrecords: true,
	           hidegrid: false,
	           multiselect : false,
	           multiboxonly:false,  
	           beforeSelectRow: false,
	           onSelectRow:function(id){
	         	  lastSel=id;
	           },
	           jsonReader: {
	                root: "result.rows",
	                page: "result.page",
	                total: "result.total",
	                records: "result.records",
	                repeatitems: false,
	                id: "replaceId"
	          },
	          loadComplete:function(datas){
	        	  if (datas.flag == "100100") {
	                  layer.msg("查询成功!", {icon: 6, time: 1000});
	                  return;
	              }
	        	  
	        	  if(datas.flag == '100802') {
					  top.location.href = thisLoginUrl;
					  return;
				  }
	              layer.msg(datas.message, {icon: 2});
	          }
	  });
	} else {
		 var postData = $("#table_list_2").jqGrid("getGridParam", "postData");
 		 $.extend(postData, {busiId:busiId});
         $("#table_list_2").jqGrid("setGridParam", { search: true }).trigger("reloadGrid", [{ page: 1}]);
	}
}
/*收支管理概要*/
function cwIncomeExpensesDetail(url){
	$.dpAjax({
		show:true,
 		url:url,
		data:{busiId:busiId},
		success: function(datas){
		  if(datas.flag == "100100"){
			  var data = datas.result;
			  if(data) {
				  //收支管理
 				 var cwIncomeExpenses = data.cwIncomeExpenses;
 				 if(cwIncomeExpenses) {
 					$('#shouzhi_income_remarks').val(cwIncomeExpenses.remarks);
 					$('#shouzhi_dateComplete').val(formateDate(cwIncomeExpenses.dateComplete));
 				 } else {
 					$('#shouzhi_income_remarks').val('-');
 					$('#shouzhi_dateComplete').val('-');
 				 }
			  }
			  return;
		   }
		  if(datas.flag == "100200"){
			  $.fn.showDatas({"datas":datas});
			  return;
          }
		 layer.msg(datas.message, {icon: 2});
     }
 	});
}